package com.cssw.fyzb.busi.service.pay;

import com.cssw.fyzb.core.dao.pay.*;
import com.cssw.fyzb.core.model.dodb.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @author yangyiqun
 * @Date 20210211
 */
@Service
public class QuickPayServiceImpl implements QuickPayService {

    private static final Logger logger = LoggerFactory.getLogger(QuickPayServiceImpl.class);

    @Autowired
    private UserQuickSignDao userQuickSignDao;

    @Autowired
    private QuickRequestLogDao quickRequestLogDao;

    @Autowired
    private QuickNotifyLogDao quickNotifyLogDao;

    @Autowired
    private QuickSignOrderDao quickSignOrderDao;

    @Autowired
    private QuickPayOrderDao quickPayOrderDao;

    @Override
    public UserQuickSign getUserQuickSignByUserId(Long userId) {
        return userQuickSignDao.getByUserId(userId);
    }

    @Override
    public UserQuickSign getUserQuickSignByUIdAndCardNo(Long userId, String cardNo) {
        return userQuickSignDao.getByUIdAndCardNo(userId, cardNo);
    }

    @Override
    public Long saveUserQuickSign(Long userId, String cardNo, String realName, String bankName, String bankCode,
                              String certCode, String mobile, String orderNo, String idCard) {
        return userQuickSignDao.save(userId, cardNo, realName, bankName, bankCode, certCode, mobile, orderNo, idCard);
    }

    @Override
    public void saveQuickRequestLog(Long userId, String orderNo, String busiNo, String type, String errorCode, String errorMsg, String reqParam, String respParam) {
        quickRequestLogDao.save(userId, orderNo, busiNo, type, errorCode, errorMsg, reqParam, respParam);
    }

    @Override
    public void saveQuickNotifyLog(Long userId, String orderNo, String busiNo, String type, String errorCode, String errorMsg, String param) {
        quickNotifyLogDao.save(userId, orderNo, busiNo, type, errorCode, errorMsg, param);
    }

    @Override
    public void saveQuickSignOrder(Long userId, String cardNo, String realName, String bankName, String bankCode, String certCode, String mobile, String orderNo, String idCard, String busiNo) {
        quickSignOrderDao.save(userId, cardNo, realName, bankName, bankCode, certCode, mobile, orderNo, idCard, busiNo);
    }

    @Override
    public void saveQuickPayOrder(Long userId, String certCode, String busiType, BigDecimal amount, String goodsName, String goodsDesc, String orderNo, String busiNo) {
        quickPayOrderDao.save(userId, certCode, busiType, amount, goodsName, goodsDesc, orderNo, busiNo);
    }

    @Override
    public QuickSignOrder getQuickSignOrderByOrderNo(String orderNo){
        return quickSignOrderDao.getByOrderNo(orderNo);
    }

    @Override
    public QuickPayOrder getQuickPayOrderByOrderNo(String orderNo){
        return quickPayOrderDao.getByOrderNo(orderNo);
    }

    @Override
    public void updateQuickSignSucc(Long signId) {
        quickSignOrderDao.updateSuccess(signId);
    }

    @Override
    public void updateQuickSignFail(Long signId, String errorCode, String errorMsg) {
        quickSignOrderDao.updateFail(signId, errorCode, errorMsg);
    }

    @Override
    public void updateQuickPaySucc(Long payId) {
        quickPayOrderDao.updateSuccess(payId);
    }

    @Override
    public void updateQuickPayFail(Long payId, String errorCode, String errorMsg) {
        quickPayOrderDao.updateFail(payId, errorCode, errorMsg);
    }
}
